/**
 * 
 */
package net.yters.model.agents.actuators;

import java.util.ArrayList;

import net.yters.model.agents.DeciderAgent;
import net.yters.util.Box;
import net.yters.util.Util;

public class DamageActuator extends ActuatorAgent {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5079795097204783697L;
	Box f_damage = new Box(new Double(1));
	
	public DamageActuator() {
		super();
		addBoxedParameter("damage", f_damage);
	}
	
	@Override
	public void execute() {
        ArrayList<Object> newPos = new ArrayList<Object>(
        		Util.add(
        				Util.disemBoxArray(f_ownerAgent.f_position), 
        				Util.disemBoxArray(f_ownerAgent.f_direction)));
		
        DeciderAgent damagedAgent = f_ownerAgent.f_model.lookupAgent(newPos); 
        
        if(damagedAgent != null) {
			damagedAgent.f_hp.f_value = (Double) damagedAgent.f_hp.f_value - (Double) f_damage.f_value;
		} 
	}
	
}